numRows = 5
def generate(numRows):
    dp=[[0 for _ in range(numRows)] for _ in range(numRows)]
    #先处理第一行
    dp[0][0]=1
    #处理剩余行
    for i in range(1,numRows):
        for j in range(0,i+1):
            if j==0:
                dp[i][j]=dp[i-1][j]
            if j==i:
                dp[i][j]=dp[i-1][j-1]
            if j>0 and j<i:
                dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
    list1=[]
    for i in range(numRows):
        list2=[]
        for j in range(i+1):
            list2.append(dp[i][j])
        list1.append(list2)

generate(numRows)